<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>窗口操作</title>
</head>
<body>
    <button id="btn">打开新窗口</button>
    <button id="btn1">关闭窗口</button>
</body>
<script>
    var btn = document.getElementById("btn");
    var btn1 = document.getElementById("btn1");
    var newWindow;
    btn.onclick = function(){
        newWidow = window.open("http://baidu.com","text", "width=100px ,heigth=200px");//可以打开其他文件，设置窗口大小
    }
    btn1.onclick = function(){
        newWindow.close();
    }

</script>
</html>